package convert

import (
	"context"
	"octopus/user/dto"
	"octopus/user/infra/po"
	"octopus/user/model/domain/user"
)

const (
	NotCreateUserID = 0
)

func CreateUserDTO2User(ctx context.Context, request *dto.CreateUserRequest) *user.User {
	return user.NewUser(ctx, NotCreateUserID, request.Name, request.Password, request.Email, request.Mobile, request.Telephone, request.DescInfo)
}

func UserDomain2Po(userDomain *user.User) *po.User {
	u := &po.User{}
	u.ID = userDomain.AggregateRoot.Id()
	u.Name = userDomain.GetUsername()
	u.Password = userDomain.GetPassword().Get()
	u.Email = userDomain.GetEmail().GetEmail()
	u.Mobile = userDomain.GetMobile().GetMobile()
	u.Telephone = userDomain.GetTelephone()
	u.DescInfo = userDomain.GetDescInfo()
	return u
}
